/*************************************************************************
	> File Name: 009.牛顿迭代法实现sqrt函数.c
	> Author: Maureen 
	> Mail: Maureen@qq.com 
	> Created Time: 三  8/25 12:01:32 2021
 ************************************************************************/

#include <stdio.h>
#include <math.h>

//x2 = x1 - f(x1) / f'(x1) => x -= f(x) / f'(x)
//针对的是函数y = x^2 - n


double F(double x, double n) {
    return x * x - n;
}

double f(double x) {
    return 2 * x; //x^2 - n的导数为2x
}

double newTon(double (*F)(double, double), double (*f)(double), double n) {
    double x = n / 2.0;
    #define EPSL 1e-6
    while (fabs(F(x, n)) > EPSL) {
        x -= F(x, n) / f(x);
    }
    #undef EPSL
    return x;
}

double my_sqrt(double n) {
    return newTon(F, f, n);
}

int main() {
    double n;
    while (~scanf("%lf", &n)) {
        printf("%g\n", my_sqrt(n));
    }

    return 0;
}
